""" 
按键1,2,3,4 控制继控制灯D1,D22,D3,D4
"""

# 导入Pin模块
from machine import Pin
import time

key1 = Pin(14, Pin.IN, Pin.PULL_UP)
key2 = Pin(27, Pin.IN, Pin.PULL_UP)
key3 = Pin(26, Pin.IN, Pin.PULL_UP)
key4 = Pin(25, Pin.IN, Pin.PULL_UP)
keys = [key1,key2,key3,key4]

led1 = Pin(15, Pin.OUT)
led2 = Pin(2, Pin.OUT)
led3 = Pin(0, Pin.OUT)
led4 = Pin(4, Pin.OUT)
leds = [led1,led2,led3,led4]

print("key scan start")
while True:
    for id in range(len(keys)):
        if keys[id].value() == 0:
            leds[id].value(1)
        else:
            leds[id].value(0)
        time.sleep(0.1)
print("key scan end")
